Repository navigation
fix(upload,metadata): self-heal videos stuck in uploaded - #86
Merged
Merged
Conversation
A video row is created before the bytes land, so an upload that never completes (closed tab, lost resume key, publish failure, recreated queue) stayed in 'uploaded' forever and the player spun endlessly. The upload service now reconciles stale rows: it re-publishes video.uploaded when the original exists in MinIO (lost event) and aborts the multipart session plus marks failed when it does not (abandoned upload), backed by a new internal /internal/videos/stale endpoint and UPLOAD_STALE_TTL_SECONDS / UPLOAD_RECONCILE_INTERVAL_SECONDS knobs. The feed also now hides non-ready videos from everyone but the owner.
While a video is in 'uploaded' the player said "Transcoding…", which hid that the upload itself had not finished (or was abandoned). Label the state honestly so the stuck-upload case is not mistaken for transcoding.
The interrupted-resume case never called /complete, so every e2e run left a video stuck in 'uploaded'. Finish the upload so the test does not pollute the feed with abandoned rows.
requires-python = ">=3.14" has no upper bound and the repo had no .python-version, so uv selected the newest interpreter (cpython-3.15.1) on clean CI runners. psycopg-binary 3.3.4 ships only cp314 wheels, so installing the auth env failed and took lint-py/test-py down (main red since 2026-10-09). Pin both services to 3.14, matching the python:3.14-slim images and the py314 black/mypy/ruff targets. Locally the breakage was masked because a 3.14 interpreter was already installed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A video row is created in metadata before the bytes land (
status='uploaded'by default), and the only transition out ofuploadedis the transcoder consumingvideo.uploaded. So any upload that never reachescomplete— closed tab, lost resume key, aborted e2e run, publish failure, or a queue recreated by topology self-heal — left a row hanging inuploadedforever. The player polls forever and shows an endless "Transcoding…" spinner.What
services/upload/internal/reconciler). EveryUPLOAD_RECONCILE_INTERVAL_SECONDSit takesuploadedrows older thanUPLOAD_STALE_TTL_SECONDSand:video.uploadedwhenraw/{id}/original.mp4exists → recovers a lost event (transcoder is idempotent, skipsready/failed);failedotherwise → resolves an abandoned upload.GET /internal/videos/stale?older_than_seconds=&limit=endpoint +VideoRepo.ListStaleUploaded+model.StaleUpload.MetadataClient.ListStaleUploaded/SetStatus,MinioClient.AbortMultipartUpload, reconciler wiring incmd/server; new env knobs in.env.exampleanddeploy/docker-compose.yml.GET /api/v1/videosnow shows onlypublic+readyto everyone; the owner still sees their own non-readyvideos (uploaded/processing/failed) to delete or re-upload. Non-ready junk no longer leaks to other users.uploadedthe watch page says "Waiting for upload…" instead of "Transcoding…"./complete, so runs no longer leaveuploadedzombies.Verification
go test ./...(metadata, upload) green;golangci-lint run0 issues;npm run lintclean.failedin one reconciler pass (no manual SQL).ready; owner feed returned itsready+failedrows.make e2ePASS (presign / multipart / resumable flows; resumed upload now reachesready).Notes
services/metadata/docs(swagger) not regenerated —swagisn't installed locally; the new endpoint is annotated and will appear aftermake swagger.UPLOAD_STALE_TTL_SECONDS, its row may be failed — raise the TTL for slow links.